﻿Imports Infragistics.Win.UltraWinGrid
Public Class VatTu_DonViTinh
    Private Sub NhomNguoiDung3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'load dữ liệu
        Me.Cursor = Cursors.WaitCursor
        'TODO: This line of code loads data into the 'ErpharmaDataSet.dmvattu_hoatchat' table. You can move, or remove it, as needed.
        Me.Dmvattu_hoatchatTableAdapter.Fill(Me.ErpharmaDataSet.dmvattu_hoatchat)
        'TODO: This line of code loads data into the 'ErpharmaDataSet.dmvattu_hoatchat' table. You can move, or remove it, as needed.
        Me.Dmvattu_hoatchatTableAdapter.Fill(Me.ErpharmaDataSet.dmvattu_hoatchat)
        'TODO: This line of code loads data into the 'ErpharmaDataSet.dmvattu_donvitinh' table. You can move, or remove it, as needed.
        Me.Dmvattu_donvitinhTableAdapter.Fill(Me.ErpharmaDataSet.dmvattu_donvitinh)
        'TODO: This line of code loads data into the 'ErpharmaDataSet.dmdonvitinh' table. You can move, or remove it, as needed.
        Me.DmdonvitinhTableAdapter.Fill(Me.ErpharmaDataSet.dmdonvitinh)
        'TODO: This line of code loads data into the 'ErpharmaDataSet.dmvattu' table. You can move, or remove it, as needed.
        Me.DmvattuTableAdapter.Fill(Me.ErpharmaDataSet.dmvattu)

        'set doi tuong cho ultragrid
        Me.VattuIUltraGrid_DanhSach.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmvattu, Me.DmvattuBindingSource, Me.DmvattuTableAdapter, Me.ErpharmaDataSet)
        Me.VattuIUltraGrid_ThongTin.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmvattu, Me.DmvattuBindingSource, Me.DmvattuTableAdapter, Me.ErpharmaDataSet)
        Me.Vattu_menu_Donvitinh_IUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmvattu_donvitinh, Me.Dmvattu_donvitinhBindingSource, Me.Dmvattu_donvitinhTableAdapter, Me.ErpharmaDataSet)
        Me.Dmvattu_hoatchatIUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmvattu_hoatchat, Me.Dmvattu_hoatchatBindingSource, Me.Dmvattu_hoatchatTableAdapter, Me.ErpharmaDataSet)
        Me.Vattu_menu_Donvitinh_TimKiem_IUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmvattu_donvitinh, Me.Dmvattu_donvitinhBindingSource, Me.Dmvattu_donvitinhTableAdapter, Me.ErpharmaDataSet)
        Me.Vattu_menu_Hoatchat_TimKiem_IUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmvattu_hoatchat, Me.Dmvattu_hoatchatBindingSource, Me.Dmvattu_hoatchatTableAdapter, Me.ErpharmaDataSet)
        '=======================================================================
        'set giao dien
        Me.VattuIUltraGrid_ThongTin.setGiaoDien_Doi_ThongTin()
        Me.VattuIUltraGrid_DanhSach.setGiaoDienTuDong()
        'set them Iultradropdown
        Me.VattuIUltraGrid_DanhSach.setThemIUltraDropDown(DmdonvitinhIUltraDropDown, Me.ErpharmaDataSet.dmdonvitinh)
        Me.VattuIUltraGrid_ThongTin.setThemIUltraDropDown(DmdonvitinhIUltraDropDown, Me.ErpharmaDataSet.dmdonvitinh)

        Me.Vattu_menu_Donvitinh_IUltraGrid.setGiaoDienTuyBien()
        Me.Dmvattu_hoatchatIUltraGrid.setGiaoDienTuyBien()

        Me.Vattu_menu_Donvitinh_TimKiem_IUltraGrid.setGiaoDienTuyBien()
        Me.Vattu_menu_Hoatchat_TimKiem_IUltraGrid.setGiaoDienTuyBien()

        Me.DmthoigianIUltraCombo.setGiaoDien()
        Me.DmdonvitinhIUltraDropDown.setGiaoDien()

        '=======================================================================
        'set tìm kiếm
        Me.VattuIUltraGrid_DanhSach.setTimKiemTrenCotUltraGrid()
        Me.Vattu_menu_Donvitinh_TimKiem_IUltraGrid.setTimKiemTrenCotUltraGrid()
        Me.Vattu_menu_Hoatchat_TimKiem_IUltraGrid.setTimKiemTrenCotUltraGrid()
        '=======================================================================
        'set cot bat loi
        Me.VattuIUltraGrid_ThongTin.setCotBatLoi("ma")
        Me.VattuIUltraGrid_ThongTin.setCotBatLoi("ten")
        '=======================================================================
        'set group by - iultragrid timkiem
        Me.Vattu_menu_Donvitinh_TimKiem_IUltraGrid.setGroupBy("ma")
        Me.Vattu_menu_Hoatchat_TimKiem_IUltraGrid.setGroupBy("ma")
        '=======================================================================
        'set menustrip
        Me.Vattu_menu_Donvitinh_IUltraGrid.setChoPhepMenuStrip()
        Me.Dmvattu_hoatchatIUltraGrid.setChoPhepMenuStrip()

        '=======================================================================
        Me.DmvattuBindingSource.MoveLast()
        If VattuIUltraGrid_ThongTin.Rows.Count > 0 Then
            VattuIUltraGrid_ThongTin.ActiveRowScrollRegion.ScrollRowIntoView(Me.VattuIUltraGrid_ThongTin.Rows(Me.VattuIUltraGrid_ThongTin.Rows.Count - 1))
        End If
        Me.setReadonly(True)
        Me.Cursor = Cursors.Default
    End Sub
    Private Sub setReadonly(ByVal isTrue As Boolean)
        Me.VattuIUltraGrid_DanhSach.setReadonly(isTrue)
        Me.VattuIUltraGrid_DanhSach.setReadonly(isTrue)
        Me.Vattu_menu_Donvitinh_TimKiem_IUltraGrid.setReadonly(isTrue)
    End Sub

    Private Sub btnTaoMoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTaoMoi.Click
        'Me.NhomnguoidungIUltraGrid_ThongTin.setMacDinh("ma", getMa)
        If (Me.VattuIUltraGrid_ThongTin.getTaoMoi()) Then
            Me.setReadonly(False)
        End If
    End Sub

    Private Sub btnLuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLuu.Click
        If Me.VattuIUltraGrid_ThongTin.getLuu() Or Me.Vattu_menu_Donvitinh_TimKiem_IUltraGrid.getLuuNgam() Then
            Me.setReadonly(True)
        End If
    End Sub

    Private Sub btnXoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXoa.Click
        Me.VattuIUltraGrid_ThongTin.getXoa()
    End Sub

    Private Sub btnLamTuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLamTuoi.Click
        Me.VattuIUltraGrid_ThongTin.getRefresh()
    End Sub

    Private Sub btnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIn.Click
        'MessageBox.Show(Me.Ketoantienmatchitiet_ThongTinKhaiThue_IUltraGrid.Rows(2).ChildBands(0).Rows.SummaryValues("doanhthu").Value)
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Dispose()
        Me.Close()
    End Sub
    'Xu ly : khi chon cot dvt cua dmvattu(thong tin)->tu dong them dong duoi phan don vi tinh:
    'Gom: ma (tu dong tu cha), so luong =1, dvt= dvt phan thong tin, ten dvt = ten dvt thong tin,loai dvt=1
    Private Sub VattuIUltraGrid_ThongTin_AfterCellListCloseUp(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles VattuIUltraGrid_ThongTin.AfterCellListCloseUp
        If VattuIUltraGrid_ThongTin.ActiveRow.Cells("dvt").IsActiveCell = True Then
            Me.Vattu_menu_Donvitinh_TimKiem_IUltraGrid.DisplayLayout.Bands(0).AddNew()
        End If

    End Sub

    Private Sub NhomnguoidungIUltraGrid_ThongTin_BeforeCellDeactivate(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles VattuIUltraGrid_ThongTin.BeforeCellDeactivate, VattuIUltraGrid_ThongTin.BeforeCellDeactivate
        'If Me.NhomnguoidungIUltraGrid_ThongTin.ActiveRow.Cells("ma").IsActiveCell Then
        '    Me.NhomnguoidungIUltraGrid_ThongTin.getLuuNgam()
        'End If
        If Me.VattuIUltraGrid_ThongTin.ActiveRow.Cells("tinhtrang").IsActiveCell Then
            Me.VattuIUltraGrid_ThongTin.setFocusCellUltraGrid(Me.Vattu_menu_Donvitinh_TimKiem_IUltraGrid)
        End If
    End Sub
    Private Sub btnSua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSua.Click
        If Me.VattuIUltraGrid_ThongTin.getSua Then
            Me.setReadonly(False)
        End If
    End Sub
End Class